package com.anyou.mall.pla.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.pla.domain.UseUserGoodsReport;
import com.anyou.mall.pla.service.IUseUserGoodsReportService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 举报管理Controller
 *
 * @author xq
 * @date 2022-04-30
 */
@Api(tags = "举报管理")
@RestController
@RequestMapping("/help/userReport")
public class UseUserGoodsReportController extends BaseController
{
    @Autowired
    private IUseUserGoodsReportService useUserGoodsReportService;

    /**
     * 查询举报管理列表
     */
    @ApiOperation("查询举报管理列表")
    @PreAuthorize("@ss.hasPermi('help:userReport:list')")
    @GetMapping("/list")
    public TableDataInfo<List<UseUserGoodsReport>> list(UseUserGoodsReport useUserGoodsReport)
    {
        startPage();
        List<UseUserGoodsReport> list = useUserGoodsReportService.selectUseUserGoodsReportList(useUserGoodsReport);
        return getDataTable(list);
    }

    /**
     * 查询举报管理列表
     */
    @ApiOperation("举报管理已处理")
    @PreAuthorize("@ss.hasPermi('help:userReport:status')")
    @GetMapping("/status")
    public ApiResult status(@RequestParam("reportId") String reportId)
    {

        return useUserGoodsReportService.status(reportId);
    }


    /**
     * 导出举报管理列表
     */
    @ApiOperation("导出举报管理列表")
    @PreAuthorize("@ss.hasPermi('help:userReport:export')")
    @Log(title = "举报管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UseUserGoodsReport useUserGoodsReport)
    {
        List<UseUserGoodsReport> list = useUserGoodsReportService.selectUseUserGoodsReportList(useUserGoodsReport);
        ExcelUtil<UseUserGoodsReport> util = new ExcelUtil<UseUserGoodsReport>(UseUserGoodsReport.class);
        util.exportExcel(response, list, "举报管理数据");
    }

    /**
     * 获取举报管理详细信息
     */
    @ApiOperation("获取举报管理详细信息")
    @PreAuthorize("@ss.hasPermi('help:userReport:query')")
    @GetMapping(value = "/{reportId}")
    public ApiResult<UseUserGoodsReport> getInfo(@PathVariable("reportId") Long reportId)
    {
        return ApiResult.success(useUserGoodsReportService.selectUseUserGoodsReportByReportId(reportId));
    }

    /**
     * 新增举报管理
     */
    @ApiOperation("新增举报管理")
    @PreAuthorize("@ss.hasPermi('help:userReport:add')")
    @Log(title = "举报管理", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody UseUserGoodsReport useUserGoodsReport)
    {
        return ApiResult.success(useUserGoodsReportService.insertUseUserGoodsReport(useUserGoodsReport));
    }

    /**
     * 修改举报管理
     */
    @ApiOperation("修改举报管理")
    @PreAuthorize("@ss.hasPermi('help:userReport:edit')")
    @Log(title = "举报管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody UseUserGoodsReport useUserGoodsReport)
    {
        return ApiResult.success(useUserGoodsReportService.updateUseUserGoodsReport(useUserGoodsReport));
    }

    /**
     * 删除举报管理
     */
    @ApiOperation("删除举报管理")
    @PreAuthorize("@ss.hasPermi('help:userReport:remove')")
    @Log(title = "举报管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{reportIds}")
    public ApiResult remove(@PathVariable Long[] reportIds)
    {
        return ApiResult.success(useUserGoodsReportService.deleteUseUserGoodsReportByReportIds(reportIds));
    }
}
